package com.quzi.kettle.api.response;

import org.json.JSONObject;

import com.example.httprequest.BaseResponseHandler;

import android.util.Log;

public abstract class UpdateInfoResponse<b extends String> extends BaseResponseHandler<String> {

	@Override
	public void onDataReceived(String json) {
		Log.d("quziresponse", "onDataReceive "+json);
		super.onDataReceived(json);
		onSuccess(json);
	}

	@Override
	public void onFailure(int arg0, String arg1) {
		// TODO Auto-generated method stub
		Log.d("quziresponse","onFailed "+arg1);
	}

	@Override
	public void ModifyData(String response) {
		// TODO Auto-generated method stub
		super.ModifyData(response);
		try{
			JSONObject obj = new JSONObject(response);
			baseMessage.setCode(obj.getInt(code));
			baseMessage.setMessage(obj.getString(message));
			if (baseMessage.getCode() == RESULT_OK) {
				String result = obj.getString("data");
				onSuccess(result);
			} else {
				onFailure(baseMessage.getCode(), baseMessage.getMessage());
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
}